<?php
/*
 * @Author: 李明
 * @Date: 2021-11-06 17:48:48
 * @LastEditTime: 2022-01-21 14:17:43
 * @LastEditors: 李明
 * @Description: 
 * @FilePath: /CRM2.0-PHP/app/Http/Resources/BankCard.php
 * @山东壹零贰肆信息科技有限公司
 */

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class BankCard extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
    public function toArray($request)
    {
        $bank_card = parent::toArray($request);
        switch ($this->status) {
            case '1':
                $bank_card['status_str']  = '未认证';
                break;
            case '2':
                $bank_card['status_str']  = '认证中';
                break;
            case '3':
                $bank_card['status_str']  = '已认证';
                break;
            default:
                $bank_card['status_str']  = '状态未知';
                break;
        }
        $bank_card['bank_name'] = $this->bank->bank_name ?? '';
        $bank_card['bank_obverse_images'] = $this->images->where('img_type', '5')->all();
        $bank_card['bank_verso_images'] = $this->images->where('img_type', '6')->all();
        return $bank_card;
    }
}
